package cn.com.mayue.guava.basic;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;

/**
 * Created by mayue on 2016/12/4.
 * 常用 equal   hashCode
 * 其他方法已过时，使用MoreObjects代替
 */
public class ObjectsTest {
    @Test
    public void testObjects() {
        String strOne = null;
        String strTwo = null;
        if (strOne != null && strOne.equals(strTwo)) {
            //.....
        }
        // 使用Objects比较  不用担心null  @NonNull @Nullable
        if (Objects.equal(strOne, strTwo)) {

        }
        System.out.println(Objects.equal("a", "a"));
        System.out.println(Objects.equal(null, "a"));
        System.out.println(Objects.equal("a", null));
        System.out.println(Objects.equal(null, null));
        System.out.println(Objects.hashCode("a", "b"));
    }
}
